#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

int h, m;
int a, b, c, d;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> h >> m;
    a = h / 10, b = h % 10, c = m / 10, d = m % 10;

    if(a == 2){
        if(c > 3){
            if(h == 23) cout << 0 << " " << 0 << '\n';
            else cout << h + 1 << " " << 0 << '\n';
        }else{
            cout << h << " " << m << '\n';
        }
    }else{
        if(b >= 6){
            cout << (a + 1) * 10 << " " << 0 << '\n';
        }else{
            cout << h << " " << m << '\n';
        }
    }


    return 0;
}